angular.module('custom.date', [])

.run(function($scope){
        $scope.goBack=function(){
            history.go(-1);
        }
        $scope.unix_timestamp = function(date){
            return date.getTime();
        }
        $scope.from_unixtime = function(unixtime){
            return new Date(parseInt(unixtime) ).toLocaleString();
        }
        $scope.format_date = function(d,format){
            var year=d.getFullYear();
            var month=d.getMonth()+1;
            var date=d.getDate();
            var hour=d.getHours();
            var minute=d.getMinutes();
            var second=d.getSeconds();

            if(format == 'time'){
                return year+"-"+month+"-"+date+"   "+hour+":"+minute+":"+second;
            }else if(format == 'date'){
                return year+"-"+month+"-"+date;
            }

        }
    });